#include <iostream>
#include <algorithm>
struct Act{
int s, d, w;
Act(){}
Act(int _s, int _d, int _w): s(_s), d(_d), w(_w) {}
~Act(){}
void set(int _s, int _d, int _w){
this->s=_s;
this->d=_d;
this->w=_w;
}
};
bool ActCmp(Act act1, Act act2){
return act1.w>act2.w;
}
struct Acts{
Act* arr;
int size, cap=0;
Acts(int _size): size(_size) {
this->arr=new Act[this->size];
}
void insert(int _s, int _d, int _w){
if(cap==size){
std::cout<<"Acts Full"<<std::endl;
exit(1);
}
arr[cap++].set(_s, _d, _w);
}
void sort(void){
std::sort(arr, arr+size, ActCmp);
}
int s(int ind){
return this->arr[ind].s;
}
int d(int ind){
return this->arr[ind].d;
}
int w(int ind){
return this->arr[ind].w;
}
};
struct Array{
int* arr;
int sz, cap=0;
Array(int _sz): sz(_sz) {
arr=new int[sz];
}
void insert(int ind){
this->arr[this->cap++]=ind;
}
void print(void){
for(int i=0; i<this->cap; ++i) std::cout<<arr[i]<<' ';
std::cout<<std::endl;
}
};
void GreedyActivitySelector(Acts acts, Array& index){
acts.sort();
int n=acts.size;
int ind=0;
int l=0;
for(int m=0; m<n; ++m){
int sum=0;
for(int k=0; k<=m; ++k){
if(acts.d(k)<=l) sum++;
}
if(sum<=m){
index.insert(m+1);
l++;
}
}
}
int main(void){
Acts acts(7);
Array index(7);
int s[7]={1, 2, 3, 4, 5, 6, 7};
int d[7]={4, 2, 4, 3, 1, 4, 6};
int w[7]={70, 60, 50, 40, 30, 20, 10};
for(int i=0; i<7; ++i) acts.insert(s[i], d[i], w[i]);
acts.sort();
GreedyActivitySelector(acts, index);
index.print();
return 0;
}